package com.yysjyr.logisticssystem.settings.mapper;

import com.yysjyr.logisticssystem.settings.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

/**
 * @author: 吃货大人
 * @date: 2023/10/3
 * @time : 18:24
 * @description: 用户信息持久层
 */

public interface UserMapper {

    /**
     * @author: 吃货大人
     * @date: 2023/10/3
     * @time : 18:41
     * @param username
     * @return : User
     * @description: 根据username查询user对象
     */
    @Select("""
            select id,name,sex,username,password,email,phone,type,lock_use,create_time
            from tbl_user
            where username = #{username}
            """)
    User selectUserByUsername(String username);

    /**
     * @author: 吃货大人
     * @date: 2023/10/5
     * @time : 19:16
     * @param user 用户对象
     * @return :
     * @description: 插入新的用户信息
     */
    @Insert("""
            insert into 
            tbl_user
            (id,name,sex,username,password,email,phone,type,lock_use,create_time) 
            values(#{id},#{name},#{sex},#{username},#{password},#{email},#{phone},
            #{type},#{lockUse},#{createTime})
            """)
    int insertUserByUser(User user);

    /**
     * @author: 吃货大人
     * @date: 2023/10/24
     * @time : 22:47
     * @param username
     * @return :
     * @description: 根据 用户名查询用户id
     */
    @Select("""
            select id
            from tbl_user
            where username = #{username}
            """)
    String selectUserIdByUsername(String username);
}
